package com.kifas.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author brainmaster
 * 
 */
@Entity
@Table(name = "tb_kontrak")
public class KontrakEntity implements Serializable {

	private static final long serialVersionUID = -3214780761035521571L;

	@Id
	@GeneratedValue
	@Column(name = "id_kontrak")
	private Long idKontrak;

	@Column(name = "no_kontrak", nullable = false)
	private String nomorKontrak;

	@ManyToOne
	@JoinColumn(name = "id_supplier", nullable = false)
	private SupplierEntity supplier;

	@OneToMany(mappedBy = "kontrak", targetEntity = KontrakPembelianEntity.class, fetch = FetchType.LAZY)
	private Set<KontrakPembelianEntity> kontrakPembelians;

	@Column(nullable = false)
	@Temporal(TemporalType.DATE)
	private Date tanggal;
	
	@Column(name= "created_by")
	private String createdBy;
	
	@Column(name= "created_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;

	public KontrakEntity() {
	}

	public KontrakEntity(Long idKontrak, String nomorKontrak, SupplierEntity supplier, Set<KontrakPembelianEntity> kontrakPembelians, Date tanggal,
			String createdBy, Date createdDate) {
		this.idKontrak = idKontrak;
		this.nomorKontrak = nomorKontrak;
		this.supplier = supplier;
		this.kontrakPembelians = kontrakPembelians;
		this.tanggal = tanggal;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
	}

	public Long getIdKontrak() {
		return idKontrak;
	}

	public void setIdKontrak(Long idKontrak) {
		this.idKontrak = idKontrak;
	}

	public String getNomorKontrak() {
		return nomorKontrak;
	}

	public void setNomorKontrak(String nomorKontrak) {
		this.nomorKontrak = nomorKontrak;
	}

	public SupplierEntity getSupplier() {
		return supplier;
	}

	public void setSupplier(SupplierEntity supplier) {
		this.supplier = supplier;
	}

	public Date getTanggal() {
		return tanggal;
	}

	public void setTanggal(Date tanggal) {
		this.tanggal = tanggal;
	}

	public void setKontrakPembelians(
			Set<KontrakPembelianEntity> kontrakPembelians) {
		this.kontrakPembelians = kontrakPembelians;
	}

	public Set<KontrakPembelianEntity> getKontrakPembelians() {
		return kontrakPembelians;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

}
